"""http路由"""

import asyncio
from http_handle import stop_server
from main import app, remove_service


def init_route():
    @app.get("/")
    async def hello():
        return "hello world"

    @app.get("/cmd/{act}")
    async def do_cmd(act: str):
        if act == "stop_server":
            await remove_service()
            asyncio.get_running_loop().call_later(1, stop_server)
        else:
            return f"act[{act}] not exists!"

        return f"[{act}] success!"
